package com.wingsboat.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wingsboat.common.log.annotation.Log;
import com.wingsboat.common.log.enums.BusinessType;
import com.wingsboat.common.security.annotation.RequiresPermissions;
import com.wingsboat.system.domain.SysLineSleeper;
import com.wingsboat.system.service.ISysLineSleeperService;
import com.wingsboat.common.core.web.controller.BaseController;
import com.wingsboat.common.core.web.domain.AjaxResult;
import com.wingsboat.common.security.utils.poi.ExcelUtil;
import com.wingsboat.common.core.web.page.TableDataInfo;

/**
 * 线路轨枕数据Controller
 * 
 * @author wangzhong
 * @date 2024-07-19
 */
@RestController
@RequestMapping("/lineSleeper")
public class SysLineSleeperController extends BaseController
{
    @Autowired
    private ISysLineSleeperService sysLineSleeperService;

    /**
     * 分页查询线路轨枕数据列表
     */
    @RequiresPermissions("system:sleeper:list")
    @GetMapping("/list")
    public TableDataInfo list(SysLineSleeper sysLineSleeper)
    {
        startPage();
        List<SysLineSleeper> list = sysLineSleeperService.selectSysLineSleeperList(sysLineSleeper);
        return getDataTable(list);
    }

    /**
     * 查询线路轨枕数据列表
     */
    @RequiresPermissions("system:sleeper:list")
    @GetMapping("/listAll")
    public AjaxResult listAll( SysLineSleeper sysLineSleeper)
    {
        List<SysLineSleeper> list = sysLineSleeperService.selectSysLineSleeperList(sysLineSleeper);
        return success(list);
    }

    /**
     * 导出线路轨枕数据列表
     */
    @RequiresPermissions("system:sleeper:export")
    @Log(title = "线路轨枕数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysLineSleeper sysLineSleeper)
    {
        List<SysLineSleeper> list = sysLineSleeperService.selectSysLineSleeperList(sysLineSleeper);
        ExcelUtil<SysLineSleeper> util = new ExcelUtil<SysLineSleeper>(SysLineSleeper.class);
        util.exportExcel(response, list, "线路轨枕数据数据");
    }

    /**
     * 获取线路轨枕数据详细信息
     */
    @RequiresPermissions("system:sleeper:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysLineSleeperService.selectSysLineSleeperById(id));
    }

    /**
     * 新增线路轨枕数据
     */
    @RequiresPermissions("system:sleeper:add")
    @Log(title = "线路轨枕数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysLineSleeper sysLineSleeper)
    {
        return toAjax(sysLineSleeperService.insertSysLineSleeper(sysLineSleeper));
    }

    /**
     * 修改线路轨枕数据
     */
    @RequiresPermissions("system:sleeper:edit")
    @Log(title = "线路轨枕数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysLineSleeper sysLineSleeper)
    {
        return toAjax(sysLineSleeperService.updateSysLineSleeper(sysLineSleeper));
    }

    /**
     * 删除线路轨枕数据
     */
    @RequiresPermissions("system:sleeper:remove")
    @Log(title = "线路轨枕数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysLineSleeperService.deleteSysLineSleeperByIds(ids));
    }
}
